package com.kotlinvben.utils

import com.kotlinvben.entity.User
import org.springframework.security.core.context.SecurityContextHolder

object SecurityUtils {
    fun getCurrentUserId(): Long? {
        return getCurrentUser()?.id
    }

    fun getCurrentUsername(): String? {
        return getCurrentUser()?.username
    }

    fun getCurrentUser(): User? {
        val authentication = SecurityContextHolder.getContext().authentication
        return authentication?.principal as? User
    }
}